﻿/**********************************************************************
 * @file   FITKAbstractFESubSys.h
 * @brief  FE子系统抽象基类数据声明
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date   2024-12-17
 *********************************************************************/
#ifndef _FITK_ABSTRACT_FE_SUB_SYS_H___
#define _FITK_ABSTRACT_FE_SUB_SYS_H___
 
#include "FITKAcousticsModelAPI.h"
#include "FITK_Kernel/FITKCore/FITKAbstractNDataObject.h"
#include "FITK_Kernel/FITKCore/FITKAbstractDataManager.hpp"

namespace Interface
{
    class FITKUnstructuredMesh;
}

namespace Acoustics
{
    class FITKFESubSysGeoProp;
    /**
     * @brief  FE子系统抽象类
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2024-12-13
     */
    class FITKAcousticsModelAPI FITKAbstractFESubSys : public Core::FITKAbstractNDataObject
    {
        Q_OBJECT
    public:
        /**
         * @brief  FE子系统类型
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-13
         */
        enum FESubSysType
        {
            FENone,                     ///< 空
            FEStructure,                ///< 结构
            FEAcoustic,                 ///< 声腔
        };
        Q_ENUM(FESubSysType);

        /**
         * @brief Construct a new FITKAbstractFESubSys object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-13
         */
        explicit FITKAbstractFESubSys();
        /**
         * @brief Destroy the FITKAbstractFESubSys object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-13
         */
        virtual ~FITKAbstractFESubSys();
        /**
         * @brief 获取子系统类型
         * @return FESubSysType
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-13
         */
        virtual FESubSysType getFESubSysType() = 0;
        /**
         * @brief 更新几何属性
         * @return bool
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-13
         */
        virtual bool updateGeoProp();
        /**
         * @brief    获取几何属性
         * @return   FITKFESubSysGeoProp *
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-15
         */
        FITKFESubSysGeoProp* getGeoProp();
        /**
         * @brief    设置单元
         * @param[i] elems 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-18
         */
        virtual void setElements(QList<int>& elems);
        /**
         * @brief    获取节点ID列表
         * @return   QList<int>
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-13
         */
        virtual QList<int> getNodesID();
        /**
         * @brief    获取单元ID列表
         * @return   QList<int>
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-18
         */
        virtual QList<int> getElementsID();
        /**
         * @brief    获取全部单元属性的ID
         * @param    isFEProperty
         * @return   QList<int>
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-02
         */
        QList<int> getAllElementPropID(bool* isFEProperty = nullptr);
        /**
         * @brief    获取全部单元的属性名称 
         * @return   QString
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-03
         */
        QList<QString> getAllElementPropName();
        /**
         * @brief    获取单元的维度
         * @return   int 1-Beam 2-Shell 3-Acoustic -1:失败
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-03
         */
        int getElementDim();
        /**
         * @brief    设置全部单元属性
         * @param[i] propID 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-02
         */
        void setAllElementPropID(int propID);
        /**
         * @brief    设置启用状态
         * @param[i] state 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-18
         */
        void setEnableState(bool state);
        /**
         * @brief    获取启用状态
         * @return   bool
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-18
         */
        bool getEnableState();
        /**
         * @brief    设置注释
         * @param[i] note 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-18
         */
        void setNote(QString note);
        /**
         * @brief    获取注释
         * @return   QString
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-18
         */
        QString getNote();
        /**
         * @brief    数据对象没有数据，需要通过FE模型获取数据时，更新网格
         * @param[i] faceMeshData partID, 表面单元ID
         * @param[i] elemSectionMap 单元与section的映射
         * @return   bool
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-11-18
         */
        virtual bool updateMesh(QHash<int, QList<int>> faceMeshData, QHash<int, int> elemSectionMap);
        /**
         * @brief    数据对象没有数据，更新网格
         * @param[i] faceMeshData
         * @param[i] dim 最大维度
         * @return   bool
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-11-18
         */
        virtual bool updateMesh(Interface::FITKUnstructuredMesh* faceMeshData, int dim);

    protected:
        /**
         * @brief  单元ID列表
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-18
         */
        QList<int> _elementsIDList{};
        /**
         * @brief  几何属性
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-15
         */
        FITKFESubSysGeoProp* _geoProp{};
        /**
         * @brief  启用状态
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-16
         */
        bool _enabledState{ true };
        /**
         * @brief  注释
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-16
         */
        QString _notes{};
    };
    /**
     * @brief FE子系统管理器
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2024-12-13
     */
    class FITKAcousticsModelAPI FITKAcousticsFESubSysManager : public Core::FITKAbstractDataObject,
        public Core::FITKAbstractDataManager<FITKAbstractFESubSys>
    {
        FITKCLASS(Acoustics, FITKAcousticsFESubSysManager);
    public:
        /**
         * @brief Construct a new FITKAcousticsFESubSysManager object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-13
         */
        explicit FITKAcousticsFESubSysManager() = default;
        /**
         * @brief Destroy the FITKAcousticsFESubSysManager object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-13
         */
        virtual ~FITKAcousticsFESubSysManager() = default;
        /**
         * @brief 根据类型获取子系统
         * @param[i]  type           子系统类型
         * @return QList<FITKAbstractFESubSys*>
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-13
         */
        QList<FITKAbstractFESubSys*> getSubSysByType(FITKAbstractFESubSys::FESubSysType type);
    };
}


#endif
